#include<bits/stdc++.h>

using i64 = long long;

int n, m;
int a[105][1005];
int ans_1[105], ans_2[105];

std::priority_queue<int> q[1005];

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            std::cin >> a[i][j];
        }
        std::sort(a[i] + 1, a[i] + 1 + m, [](int x, int y) {
            return x > y;
        });
    }


    for (int j = 1; j <= m; ++j) {
        for (int i = 1; i <= n; ++i) {
            q[j].push(a[i][j]);
        }
    }

    for (int i = 1; i <= n; ++i) {
        int vis[105] = {0};
        for (int j = 1; j <= m; ++j) {
            int flag = 0;
            if (!q[j].empty() && a[i][j] == q[j].top()) {
                q[j].pop();
                flag = 1;
            }
            for (int k = j; k <= m; ++k) {
                if (a[i][j] > q[k].top() && !vis[k]) {
                    vis[k] = 1;
                    ans_2[i]++;
                    break;
                }
            }
            if (flag) {
                q[j].push(a[i][j]);
            }
        }
    }


    for (int i = 1; i <= n; ++i) {
        std::sort(a[i] + 1, a[i] + 1 + m);
    }
    std::priority_queue<int> q2[105];
    for (int j = 1; j <= m; ++j) {
        for (int i = 1; i <= n; ++i) {
            q2[j].push(a[i][j]);
        }
    }

    for (int i = 1; i <= n; ++i) {
        int vis[105] = {0};
        for (int j = 1; j <= m; ++j) {
            int flag = 0;
            if (!q2[j].empty() && a[i][j] == q2[j].top()) {
                q2[j].pop();
                flag = 1;
            }
            for (int k = j; k <= m; ++k) {
                if (a[i][j] <= q2[k].top() && !vis[k]) {
                    vis[k] = 1;
                    ans_1[i]++;
                    break;
                }
            }
            if (flag) {
                q2[j].push(a[i][j]);
            }
        }
    }
    for (int i = 1; i <= n; ++i) {
        std::cout << m - ans_1[i] << " " << ans_2[i] << "\n";
    }
    return 0;
}
